/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package persona;

import java.sql.Connection;
import java.sql.DriverManage/**
 *
 * @author aralvarezm
 */
public class conexion {
    
    String nombreBD = "persona";
    Connection cnn = null;
    String user = "root";
    String pwd = "";
    String url = "jdbc:mysql://localhost/" + nombreBD;
    String mySqlDriver = "com.mysql.jdbc.Driver";


    public Connection conectar() {
        try {
            Class.forName(mySqlDriver);
            cnn = (Connection) DriverManager.getConnection(url, user, pwd);
            System.out.println("Conexión exitosa");
            return cnn;
        } catch (Exception e) {
            System.out.println("Error al abrir la conexión");
            return null;
        }

    }
    
}
